Looks ok, but the way the existing code is structured makes it needlessly confusing.