Modified my python code (Yu)