adding event handling
refactor the code
fixing correct class adding
refactoring even more
event handling