moved function declarations to their own var instead of defined in click() parameter