fixed very minor bug in lastNMonth function