Adding scope to function