correct bugs for 3 major functions and add 2