added some safety nets for the input