It would be nice to encapsulate the next 7 lines in a macro/function