Algorithm base and sample implementation