remove spaghetti code