moved some code and added unitests