corrected formatting note in code
improved error handling

improved method of handling errors in messages from server