make sure that buffer is always a string