fixed ugly querys and syntax