cleaned up the getTags function a bit