move similar code to same file