Refactored and made it work:)