refactored the way client/server process packets