Refatored num condition into case statement