trimmed code, added receiver lock function