move defer statement for readability Upstream-commit: 6c82fba2b32781e6cef4fda71e7b35c3dcdcb9da Component: engine