Added input validation/sanitization