Added exception check for bad parameter.