refactored according to feedback