wrote functions and tests but i am not very good at testing