updated code, didn't test yet