tighten up code for close feature