Is my implementation of genetic algorithm correct?
No, that does not make sense.

What you have there is a toy example. In any application, the algorithm will not know the goal -- otherwise you wouldn't need it! That is, you don't have any way of known whether a mutation is benefitial before executing it.

What's more, mutating away from the optimum is an essential part of the algorithm, and can be shown to be necessary for it to work well (otherwise you get stuck in local optima more easily).