image viewer code refactoring, prev-next button disabled state check