added collision detection for self and walls