Added error checking for given arguments.