each defer is a function call and not really needed here. just move it down and call it directly.