Separated javascript code into main.js