reimplmented giant if else chain