refactor reader to message buffer