A little more robust implementation.