Fixed login and read logic