Improved query used to reset passwords