Adding some boundary checks so things don't get too out of hand