Refactor to be faster