fixing bug where solve function returns a null direction