Initial working function reference implementation