moved some code to class library