almost finished with main theorem