refactored handrank code added