Converted to class (partially) and added event listener