Adding code which was altered to handle various inputs