functions for external