refactored, but need to revisit