remove function duplication, adjust comments