Second order flow function wrapping and login added