reworked javascript