add getValue, clean up solve code a bit