refactored forall to run in order of increasing length