WORKING VERSION!!! (too much debugging :( )