completely overhaul code