Error handling moved into the helper