removing redundant sql queries in the Acp