this is quite nasty, no better way like integrated into another function?