Tried to make the code faster