Improved the click detection