refactored a littel