added collision check with obstacles