added collision checking method