Code for thesis project