add common algroithm