Cleaned up and commented my A functionality code