better usage of defer