Refactored code in PYUtility.