final codes for thesis