Fixed missing variable errors