Final Javascrip code