Moved the functions to a separate file