refactoring code so that it's cleaner to read.