moved config to cfg and many util funcitons