finished writing up the function, will test the code now to see if any errors come out.