bugs fixed on select query