added fucntionality with comments