avoid out-of-memory error