click functions fixed and formatting cleaned