Fix callings on wrong pages + beautifying code