Subfunction for creating equation