Boundaries issue

The boundaries work, but the box gets stuck. I know what is happening, but I don’t know how to overcome this? You can see what I mean:[AS]
box.onEnterFrame = function() {
(this._y!==_root._ymouse&&this._y>=_root.bgmc._y&&this._y+this._height<=_root.bgmc._y+_root.bgmc._height) ? this._y -= ((this._y+this._height/2)-_root._ymouse)/10: null;
(this._x!==_root._xmouse&&this._x>=_root.bgmc._x&&this._x+this._width<=_root.bgmc._x+_root.bgmc._width) ? this._x -= ((this._x+this._width/2)-_root._xmouse)/10: null;
}
[/AS]Thanks!