Less duplicated logic in clambda.pl