improvements on the structure. Added events and triggers