Cleaned up code to add it to an archetype