Checking input before inserting a child