moved code around to more appropriate namespaces