improved code in tags controller