move the code inside of if into a partial