applies algorithms correctly