refactor detectProductId() a little bit