refactoring, comments and session added