authentication is almost done and in sync withserver code