adding events functionality + debug