changed header format and extract logic to method