added prerm function