updated close method