better implementation presented