Added input parameter range check