working but not correct implementation