refactor, added docs