Line Follower: can my code be optimized?

How is the motor powered? It is likely drawing too much power, which makes the supply voltage drop and causing a reset.