split into separate functions for readability