Splitted functions and added possibility to test