refactor box parsing