error handling for invalid parameters added