Moved function definitions in JS