replaced old code in apply.hs