corrected code example for CSP1150 lecture 2