Re-write of authentication code