A computer implemented method for revising original code based on identified patterns in the original code to replace redundancies, the method comprising: obtaining an original graph data structure comprising a plurality of stored nodes connected by a plurality of edges, the plurality of stored nodes comprising a plurality of operation stored nodes and a plurality of data stored nodes, wherein the original graph data structure represents the original code; generating an auxiliary graph data structure from the original graph data structure, wherein generating the auxiliary graph data structure comprises: adding, from the original graph data structure, the plurality of operation stored nodes to the auxiliary graph data structure while traversing the original graph data structure, replacing, when adding the plurality of operation stored nodes, a data stored node and at least two edges connecting the data stored node to at least two operation stored nodes with at least one new edge, and labelling the at least one new edge with a datatype identifier in the data stored node; executing a pattern mining tool on the auxiliary graph data structure to obtain a pattern list; traversing the auxiliary graph data structure to identify a plurality of instances of identified patterns in the pattern list; wherein datatypes of inputs and outputs, and operation types and order, are the same for each instance of a pattern; and modifying the original code to create revised code based on the plurality of instances by: creating a pattern function for an identified pattern; and replacing at least a subset of the plurality of instances in the original code matching the identified pattern with a call or reference to the pattern function. obtaining an original graph data structure comprising a plurality of stored nodes connected by a plurality of edges, the plurality of stored nodes comprising a plurality of operation stored nodes and a plurality of data stored nodes, wherein the original graph data structure represents the original code; generating an auxiliary graph data structure from the original graph data structure, wherein generating the auxiliary graph data structure comprises: adding, from the original graph data structure, the plurality of operation stored nodes to the auxiliary graph data structure while traversing the original graph data structure, replacing, when adding the plurality of operation stored nodes, a data stored node and at least two edges connecting the data stored node to at least two operation stored nodes with at least one new edge, and labelling the at least one new edge with a datatype identifier in the data stored node; adding, from the original graph data structure, the plurality of operation stored nodes to the auxiliary graph data structure while traversing the original graph data structure, replacing, when adding the plurality of operation stored nodes, a data stored node and at least two edges connecting the data stored node to at least two operation stored nodes with at least one new edge, and labelling the at least one new edge with a datatype identifier in the data stored node; executing a pattern mining tool on the auxiliary graph data structure to obtain a pattern list; traversing the auxiliary graph data structure to identify a plurality of instances of identified patterns in the pattern list; wherein datatypes of inputs and outputs, and operation types and order, are the same for each instance of a pattern; and modifying the original code to create revised code based on the plurality of instances by: creating a pattern function for an identified pattern; and replacing at least a subset of the plurality of instances in the original code matching the identified pattern with a call or reference to the pattern function. creating a pattern function for an identified pattern; and replacing at least a subset of the plurality of instances in the original code matching the identified pattern with a call or reference to the pattern function.