Consolidated the event javascript