Created a separate function to read server messages