moved functions to bmp.c