started rearranging js code