Added exceptions for invalid input