Move identical functions to separate file
Move help to separate function