Fix bug for invalid input format