Rewrite of helper logic.