Added a check for non-positive values

without this, null values were causing problems and interpreted as 0 (I
think)