optimizing codes in register page