modified the code to reflect the refactoring