Moved code into method (code quality)