Removed recursion. Separated methods