-*-pa-*- very slow algorithm implementation