added check for invalid arguments