adapted after merge