square buttons and refactor redirectIfEmpty function