removed button_to_function and added onclick html attribute