complete functionality
Refactoring