Added function which replaces variables with expressions for inlining functions