simplified reference implementation