extracting function for easier debugging