Moved js to separate file and added comments