adding sorting and stringified patterns