slight modification to main.hs and adding greg's version