Work on algorithm