perfect the function522