added epsilon check for summation to one