Removed duplicated function and added comments