udated gramar builder. clean up code