Out of memmory error fix