You can not avoid hitting a vein. You can however drawback to see if the needle is within a vein.
Everyone has a bad shot from time to time. It just happens and you just accept it.
Always practice sterile techniques and with experience you will know if you have just done a good or bad injection.