put login optionalCallback in if statement