Final code

This is fully working code