Wrote nsLogin function in its entirety.