some code for https://courses.edx.org/courses/DelftX/FP101x/3T2014/info