Separated some functions into modules