final workng version