Add some validation and re-factor fetching logic.