Removed local functions for performance