refactored and added session data back in