ex8 solution without using bl module