rewriting bitmap function (second attempt)