code deels gerefactored