working on solve function