Adjusted the flow of code and fixed set featured media issue