Final version
TODO: remove old authentication method