removed target detection and cleaned up code