refactored to handle condition where tag was at HEAD properly. fixes #4