change messages receive type to byte receive, code refactor