lib logic