Updated function to use error ids