fixed off-by-one bug in export
fixed off-by-one bug in export