adding functions and making corrections