Seperated main() function