added epsilon to <0 if statements. Default is 10-6