changeing code

getting out the sql querys