Splitted main in seperate functions for better
overview/error-control
sja