refactoring & added docs