Updated each code to fix minor bugs