first changes

Some changes to the code to convert it in a more efficient code