solver works, code needs a little cleanup