pseudo initial and refactored code