added all authentication code