Complete functions

Split the code into two file