move click logic into separate functions