Code for masters project 2014