refactors list SQL to be more readable