rearranging everything; now conforms to std=c89