JS function hackery