Started splitting up ex5 into seperate functions