baby algorithm