refactoring some functions for issue #17