Slightly less memory consumed using my approach.