first several algorithms