removed duplicated code in setSales function