http://www8.cs.umu.se/kurser/5DV011/VT13/assignment3.pdf