STM algorithm