Fixed use order.
Added missing variable.
Fixed if clause.
Added missing method call.