added parameter to change buffer size