Better implementation, with understanding