Changed sql structure