improving algorithm and avoid default #72