Refactor the addVoxel function