updated to be faster