split the code up in functions