Fix bug with misnamed function
Wrap things up in functions to keep things tidy