Fixed login form
Added check to foreach loop