Extract ids
shortcircuit instead of if-else branching