Final version for the thesis