minor modifications, refactoring