organize sql code