Improved implementation for long method.