updated functions so they work