modified to be able to test for random targets