fixing repeated code for modal in index