fix solve function