if they are diverting your bag for secondary screening then I'd be looking to see if anything in it is making it hard for the screening staff to pass it on the forst look such as If your phone and adaptor wires are a tangle for example ..
And if you are making it to the gate with 10 mins for doors close then that indicates you are there 30 mins before departure (as doors close 20 mins before) and that you got from T3 to T5 in 60 mins.