refactor for adaptability