refactored js and stuff