Course in University of Bern. Solve it yourself, but you might look at my code for inspiration.