this chunk of code is duplication, there are a few ways to dry it up but I'll let you do the one that suites you best.