Put event handler in separate func