modified login to handle erroenous attemps and redirect to index