cleaned up code with parent classes, initialize fn to work with any level