added one little error check