Cleaned up logic. Made code actually readable.