ex16: added check for argument, ask for input if none, and removed some redundancy