Problems with solve function