refactor code - still unrest