more robust initialization, remove old func