updated to remove unnecessary comments and to replace "magic numbers" with symbolic constants