added some input checking to stop assorted high jinks