increased modularity, added comments