rework based on testing
fix end of buffer