Fix solution for larger input