Seems to me you ave a bit of code duplication here, could extract it out and make it cleaner.