Move click functions out of resize function