refactor code & try to handle bitmap out of memory crash