created separate function to contain click events