Work Out algorithm