improve documentation, simplify code