Select Query Bug Fix