Updated code to use Session variables