better functiond decomposition