refactored in preparation for update functionality.