     *
     * @return {Array}
     ###
-    getMessagesByMailbox: (mailboxID, first, last) ->
+    getMessagesByMailbox: (mailboxID, first = null, last = null) ->
+        sequence = _messages.filter (message) -> mailboxID in message.get('mailboxIDs')
+        if first? and last?
+            sequence = sequence.slice first, last
+
         # sequences are lazy so we need .toOrderedMap() to actually execute it
-        _message.filter (message) -> mailboxID in message.get('mailboxIDs')
-        .toOrderedMap()
-        .slice(first, last)
+        return sequence.toOrderedMap()
 
-    getMessagesCountByMailbox: (mailboxID, first, last) ->
-        # sequences are lazy so we need .toOrderedMap() to actually execute it
-        _message.filter (message) -> mailboxID in message.get('mailboxIDs')
-        .count()
+    getMessagesCountByMailbox: (mailboxID) ->
+        return @getMessagesByMailbox(mailboxID).count()
 
     getMessagesByConversation: (messageID) ->
         idsToLook = [messageID]
         conversation = []
         while idToLook = idsToLook.pop()
             conversation.push @getByID idToLook
-            temp = _message.filter (message) -> message.get('inReplyTo') is idToLook
+            temp = _messages.filter (message) -> message.get('inReplyTo') is idToLook
             idsToLook = idsToLook.concat temp.map((item) -> item.get('id')).toArray()
 
         return conversation

        handle ActionTypes.RECEIVE_RAW_MESSAGE, onReceiveRawMessage = (message, silent = false) ->
            # create or update
            message = Immutable.Map message
            _message = _message.set message.get('id'), message

            @emit 'change' unless silent


    *
    * @return {Array}
    ###
    getMessagesByAccount: (accountID, first = null, last = null) ->
        sequence = _messages.filter (message) -> message.get('account') is accountID
        if first? and last?
            sequence = sequence.slice first, last

        # sequences are lazy so we need .toOrderedMap() to actually execute it
        return sequence.toOrderedMap()


    getMessagesCountByAccount: (accountID) ->
        return @getMessagesByAccount(accountID).count()

    ###*
    * Get messages from mailbox, with optional pagination
    *
    * @param {String} mailboxID
    * @param {Number} first     index of first message
