Refactored hs solution & added second for py