This has been done loads of times on the forum.
Here is one such answer that you should be able to adapt.