=cleaned up code significantly