I've noticed a little error in the sent patch,
sending fixed one.