Solved problem 3 through event management