Added utility function to improve code reuse.