Added search option and corrected reg null error