Fix: Add a validation logic into getAttribute function in to prevent errors.