working log in from local host, but code duplication