online algorithm works fine