refactored stages