improved python wrapper