clearer algorithm