squashed huge input bug and protected input from overflow