Writing the function

Just filled the functions and anotated everythinf