Cleaned up tag adding code