refactored code to conform to the latest language features