add open and end functions