Added optional closure to login method