See: labb 6 @ https://www.ida.liu.se/~TDDD86/info/labs.sv.shtml