oky I avoid this problem by placing If statement " If but1=0 " which all commands inside this if statement will not execute untill I press the button placed on portb.2
You sure did...missed that one, but it's still a valid point for future reference.

but I want to ask if there is something wrong in my code
Does it work?

If code_works = 1 then
nothing_wrong_with_code = 1
else
nothing_wrong_with_code = 0
something_wrong_with_code = 1
endif