cleaned up function management