refactored js and can display winner