update documentation, tweak implmenetation