added some helper functions to make things (somewhat) clearer