Refactoring code and redesigning model from scratch in C