Restructed code & added functionality for verifying token