Finished JS code