refactored old code