fixed out of memory bug