Refactor for performance... I hope