Modifying code to be faster