These are the final functions and they work