fixed some magic numbers
used session variables