Fixed error in logic. Simplified 004