Separated some functions into files