record_ns as seperate function
code cleanup