trying to organize the code