added direction test, starting loop function