Refact login system