moved events code to handler class