Move this into it's own function