some name changes and helper functions added