Refactored code for conciseness when searching notes by ID