Add event listener, reorganize a bit