On this forum a similar question has been answered. It contains some code examples that are helpful I think.