new sql querys and fixed the login to match in application context.