separate file utility functions from main.c