added simple error check