merged @mekya's changes