check for !null && !undefined before Buffer check