changed everything to functions