reorganized mul function