updated and cleaned up