move defer statement for readability Upstream-commit: 88aca3610fecdf790c4604ed705d31f8d17ef8e6 Component: engine