Refectors .js stuff. Need to get feedback though