main cleaned-up