organized and cleaned up useless code