added check for obstacles