Bugfix - required variable missing, better data validation used