splitted code into private and public parts