added feautures, refactoring