added cover function
some minor refactoring