replaced match with function