updated and cleaned up finally