working function with comments