Move some function to separate files