much safer way to check input