refactoring to reflect code in master