Filled out the functions

Need to add some comments to the top