implemented new features, refactored code