put login into prepare function