added printf for error cases