adding coins in the app

i am adding 9 coins in the app after buy if coins less then 5 then dont go next screen if coins more than 5 then it will go to next screen and 5 coins will be deducted are these blocks are ok for this dear