Searching the forum would give you nice code for the same.