Usually its fry the onions, add garlic and ginger, fry, add spices fry for just a bit and then add the tomatoes or meat to stop them from burning. OR after frying the onions and stuff add the tomatoes and cook em till the oil seperates and then add the spices and cook them a while.