Cleaned up code by making better use of partials