Copied code from RazorSpy repo