Refactoring the code for submissions page