Added event handling fucntionality