Hit Test Problem

I have searched the foru and read the tutorial on how to do this so I tried to get my own code out of it…
What Im doing is I have a character and he can walk around… whenever he gets to a wall I want him to stop…
here is my code

onClipEvent (enterFrame) {
if (wall1.hitTest(getBounds(_root).xMax, _y, true)) {
				_x -= 1;
			if (wall1.hitTest(getBounds(_root).xMin, _y, true)) {
				_x += 1;
			if (wall1.hitTest(_x, getBounds(_root).yMax, true)) {
				_y -= 1;
			if (wall1.hitTest(_x, getBounds(_root).yMin, true)) {
				_y += 1;

All Help is appreciated