added collision check