Add try and catch blocks to calculate_click function