code refactoring
merge brett's comments