fixed naiv impl
nearly fixed faster tree