Master Code without 2 sql 2nd

code local tested