worked on loop method