refactored Chapter7.kat