better error handling (handles case where remainder goes negative in between 2 observations)