Make the extractExpressions function smaller