put things into tryfinally in case of errror