i don't think this is robust enough. is there another way to do this?