added refactored verson