update lock and calculate functions. added better alerts