Added checks for buffer