added animation and cleaned up click handler logic