bit of code refactoring