added a header, cleaned up .c accordingly