Refactored functions into different files