refactored using this