Replace print 'err str' with raise ValueError('str') for clairty of err msg
Edit to return None on negative values to match specification