Re-factored to match coding standard.