added input validation and removed connect-flash dependency