fixing x button code