organizing a little the code