code simplification #86 thanks to @annonn