some fix + sql