fix out of memory exception