added func
restructured login script