Refactored the item click handler.