removed redundant preprocessing function "partition()" and started using function templates