better sql and ignore deleted accounts