added nauseating kludgy kludge to stop negative values but it seems to work in the sense of not throwing an error