updated to have corrected code for / at the end bug