Begin to refactor using arraybuffer