why we need to register these two event listeners?