simplify code and update documentation