There is so much code duplication in these lines. Can you make this a little better?