bugfix to respect buffer size