LoginLogic improved and with more comments