Refactoring the code, to be according to lab instructions.