Flakes cause swim bladder issues more readily than most pellets. Use a high quality protein based pellet with the first two or three ingredients as whole fish not fishmeal or wheat. The flakes will also muck up his water quickly , that means ammonia builds up much more quickly.
The most recommended pellets on this forum are Omega One betta pellets and New Life Spectrum .
Not sure how big is the tank but more water changes always good :)