Refactor 1: fixed an issue with connecting to the server