Final Code for submission :)