intermediate commit - restructuring javascript code not finished yet