Defer should be called only from within functions