Move currentSource assignment into if else so that if the currentPage doesn't exist (such as index), it won't break.