Fixed input validation for redirect. Added checks