code refactored out and enhenced design