clean up the code significantly