Final code. We have to test it