Created new header and C file

Delegated more work to functions. Repeated code turned into
functions. Working to integrate code.