added / to validation check and fixed index out of bounds error