Either your indentation is wrong here or you have put the remove in the incorrect place.  These are outside of the when-let block but have the indentation of items in it.  If sem has been removed then we don't need to remove it from the queue, although it should not hurt anything in that case. And the log line should be OK either way, but preferably in the when-let.