fixing buffer error