Implemented collision checking