check input and loop