Simple algorithm