first try to improve the code, it works but i don't know why