finalised and tested code added how to use