Refactored p20.hs