main functions with some data handling stuff inside