refactor to eliminate redundant functions