Replace funxtion improved, associative arrays figured out.