Fix unexpected error

fixes: http://manage.dimagi.com/default.asp?69713