coded the functions

still need to do testing