bulk of login code/check written