modification for contiguous memory