Fixed bug in rename() function