Updating main.c

working on some core functions before splitting into differente source
files