some changes to save registers