Finished bacic funcs, and setup main func