finished proof of main theorem