finished coding linear mapping