login feature finally works as it should