You've repeated essentially the same code five times, factor this out to it's own function