A more complete implementation