skip unnecessary db queries on invalid input