reorganized code

broke up code into c and h files