Moved all functions to main.c