refactoring of LOC and added comments