Moved the adding of the event listener to the proper block.