Final python code. We have to test it