working but need to debug the NoneType conversion error