Remove duplicate code on open
Clean button generation code