Changed code structure to help QtCreator