fixed dice bug, refactored code