Decide what action was ongoing in the background and which was the main action or interrupting action. Use cuando & mientras to help you decide, but also ask "what happened" and look for other context clues.