Format the code in WP standard
put the auth process separate