ChatGPT - Refactored getUserData function