added more type checks on user input. that is about as defensive as i shall get