fully refactorred
fixed name error and now it works correctly