Added velocity swap to ai function