simplify code a bit #438
fix #447