naiv base algorithm