Refactoring

Cleaner implementation