rearranged UI, refactored js