made parameter error checking a bit better