Beginning of Login State Machine code