Some common algo implementation