Add variable initialization and goal check.