code organized and removed commented codes