refactored using block, following issue #27