help me make this program moore efficient