Fix error in registering listener