Adding some check to avoid errors

same comment.