reformatted to follow personal coding standards