refactoring; added new function;