prevent PHP errors and enhance logging
fix return documentation