Fix bug in python backend