Shaaban,
There is so much missing and screwed up in the code you posted I can not tell where your issue is... Where is relatedTopsQuery and wellLayer variables in your code? Why do you have several FeatureLayer ending elements with out matching opening FeatureLayer elements? You have an fx:Declarations ending element and no opening element... And many other questions.