improved code readability

extracted two inline funtions