fixed a bug which was vulnerable to replay attacks