Updated solution for a one that optimizes on lines of code.