refactor. less functions