added logic for attract loop