Refactored dominiks code