Improve function for writing expressions.