seperated main function for importing in other scripts