Make chk_login in his own function
Call the function directly
Clean function