fixed small error handling problem