improved implementation.