removed some comments and changed code structure