collision detection code added, buggy