will not fail into infinite looping and fix bug in linear approximation