Refactor
Adding types
Working example