-grouped all variables together -fixed up document click event