Wrap imap variable inside the retrieveFunction
Use indexOf for the getAllBox function
Use the waterfall to avoid the indentation