Added basic error check on input arguments