fix out of memory error