Solved problem with static callback function for events