Fixed JS and added session variables