refactored using select