added new procedures and optimized clean var procedure