Using objects, instead of switch statement