finally got my first function (wavy) rewritten