splitting recursive functions