bad code stolen from other places to try to make something work