updated code to provide guards against non integer input