Algorithm for analyzing the XRD chart to determine final crystal structure