Fix bug in determining previous/next month