code refactored one more time