Fixed the overflow

Credit goes to robinpercy's git for the idea.