add guard in the input procedure