Added checks for function inputs