added spinner and refactored