rewriting optimist to be easier to iterate over