logic should be in controller, also avoid using ifs and prefer pattern matching