removed some magic number and added more comments