First functional version in python. Still some issues to check