added more code to algorithm model