mpd: refactoring to make logic more clear