tried to make the code faster but it didnt work