difficult function fixed