Added aditional validation and fixed the URL redirect issue