Mahendra | #541 | refactoring; extracting code to be reused in a separate method