edited from master