refactored, doc added, cleanup