add error check in open