Fixed bug and added tag detection