added the solve function