Added A functionality code, still could be tweeked