Added new functions to improve the model. Next I will rewrite it