pesudo code for open close