cleaning up code and added bitmap support