fix out of memory issue