update code for proper error