Added sanitzation and replaced ternary operator with ||