added safety in while
updated test