checking input before accessing it