Refactored version 0.2