Fix solution to be more efficient