used 'array' and 'mmap' to increase efficiency