Create a general function for get_element_lines

This issue, is part of many issues aiming at improving the overall readability and sturcture of the main branch code, by creating individual generel functions.