Cleaning and Implementation of write param

untested!