Changed up some of the functions so they work properly