implemented close method