reorganized functions in new c and h files