added the buggy inline version, fixed out fn