removed functions and change structure of the code