refined re and fixed a procedure bug