bunch more analysis, sql done