fix bug that causes OutOfMemoryError