Move javascript into objects