fixed keysinorder within sanitycheck function