fixed memory error due to huge arrays