refactored stage 2