refactored, added doc