refactored and style changes