refactoring basic version