Almost working function extraction