prev_sibling method added and refactoring